aboutsummaryrefslogtreecommitdiff
path: root/src/routes/user/[user]/+page.ts
blob: 6ec3c8454c3ab02b3b984d7ef1d3c6ca8cff628d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { load_Profile } from "$houdini";
import { user } from "$lib/Data/AniList/user";
import type { LoadEvent } from "@sveltejs/kit";

export const load = async (event: LoadEvent) => {
	const username = event.params.user as string;
	const userData = await user(username, /^\d+$/.test(username));

	if (!userData) throw new Error(`User not found: ${username}`);

	return {
		...(await load_Profile({
			event,
			variables: {
				id: userData.id,
			},
		})),
		username,
		userData,
	};
};